Chapter 8\Email.htm

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Inbox</TITLE>
</HEAD>
<SCRIPT LANGUAGE=javascript>
<!--
function ShowEmail( intIndex )
{
   var xmlEmail = 
	emails.documentElement.childNodes.item( intIndex );

   to.innerText = xmlEmail.childNodes.item(0).text;
   cc.innerText = xmlEmail.childNodes.item(1).text;
   from.innerText = xmlEmail.childNodes.item(2).text;
   subject.innerText = 
		xmlEmail.childNodes.item(3).text;
   message.innerText = 
		xmlEmail.childNodes.item(4).text;
}
//-->
</SCRIPT>
<BODY>

<XML ID="user">
    <name>John Doe</name>
</XML>

<XML ID="emails">
    <EMAILS>
        <EMAIL>
            <TO>David Harding</TO>
            <CC>(empty)</CC>
            <FROM>Mary Weatherspoon</FROM>
            <SUBJECT>Reschedule Board Meeting</SUBJECT>
            <MESSAGE>You received a call from Brian this afternoon requesting that the board meeting be rescheduled.  Please advise when you get a chance. - MW</MESSAGE>
            </EMAIL>
        <EMAIL>
	    <TO>David Harding</TO>
	    <CC>(empty)</CC>
	    <FROM>Jim Bates</FROM>
	    <SUBJECT>Golf has been confirmed</SUBJECT>
	    <MESSAGE>Hey Dave!  We are on for golf on Tuesday.  See you there!</MESSAGE>
	</EMAIL>
	<EMAIL>
	    <TO>David Harding</TO>
	    <CC>(empty)</CC>
	    <FROM>The Creator</FROM>
	    <SUBJECT>Are you free for lunch?</SUBJECT>
	    <MESSAGE>Wanna talk about the new designs for the "adrenaline" project?</MESSAGE>
        </EMAIL>
        <EMAIL>
            <TO>David Harding</TO>
            <CC>Ted Williams; Johnny Bravo; Joe Martin;</CC>
            <FROM>Bill Thomas</FROM>
            <SUBJECT>Did you get the memo on the TPS reports?</SUBJECT>
            <MESSAGE>Hmmmm... yeah... I'll make sure that you get a copy of that memo.</MESSAGE>
	</EMAIL>
	<EMAIL>
	    <TO>David Harding</TO>
	    <CC>(empty)</CC>
	    <FROM>Leah</FROM>
	    <SUBJECT>Dinner reservations for 7:30</SUBJECT>
	    <MESSAGE>The reservations are confirmed for tonight and the babysitter will be here at 7:00.  See ya then! L.</MESSAGE>
	</EMAIL>
    </EMAILS>
</XML>

<!-- Display the name of the current user -->
<H1>Welcome 

 <SCRIPT LANGUAGE="JavaScript">
    var xmlUser = user.documentElement;
    document.write( xmlUser.childNodes.item(0).text );
</SCRIPT>

</H1>

<HR>
<H2>Inbox</H2>

You have <B>
<SCRIPT LANGUAGE="JavaScript">
    var xmlEmail = emails.documentElement;
    document.write( xmlEmail.childNodes.length );
</SCRIPT>

</B> unread items.
<P>
<TABLE WIDTH="100%" BORDER="1" VALIGN="TOP">
    <TR>
        <TH>Subject</TH>
	    <TH WIDTH="70%">Email</TH>
    </TR>
    <TR>
        <TD VALIGN="TOP">

<SCRIPT LANGUAGE="JavaScript">
    var intCount;
    var intTotal;
	
    var xmlNode;
	
    intTotal = xmlEmail.childNodes.length;
    for ( intCount=0; intCount < intTotal; intCount++ )
    {
        xmlNode = xmlEmail.childNodes.item( intCount );
        var strAnchor;
        
        document.write( "<A HREF=\"javascript:ShowEmail(" );
        document.write( intCount );
        document.write( ");\">" );
        document.write( xmlNode.childNodes.item( 3 ).text );
        document.write( "</A><P>" );
    }
</SCRIPT>

    <A HREF=""></A>
    </TD>
    <TD VALIGN="TOP">
    <TABLE BORDER="1" WIDTH=100%">
        <TR>
	    <TD><B>To:</B> <SPAN ID="to"></SPAN></TD>
	<TR>
	    <TD><B>CC:</B> <SPAN ID="cc"></SPAN></TD>
	<TR>
	    <TD><B>From:</B> <SPAN ID="from"></SPAN></TD>
	<TR>
	    <TD><B>Subject:</B> <SPAN ID="subject"></SPAN></TD>
	<TR>
            <TD><B>Message</B><BR>
		<SPAN ID="message"></SPAN></TD>
</TABLE>

</BODY>
</HTML>